using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Register : System.Web.UI.UserControl
{
    processUser pUser;
    protected void Page_Load(object sender, EventArgs e)
    {
        pUser = new processUser();
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtUserName.Text = "";
        txtPassword.Text = "";
        txtConfirm.Text = "";
        txtFullName.Text = "";
        txtEmail.Text = "";
        txtFoneNumber.Text = "";        
        ddlDate.SelectedIndex = 0;
        ddlMonth.SelectedIndex = 0;
        ddlYear.SelectedIndex = 0;
        txtAddress.Text = "";
        txtUserName.Focus();
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string UserID = pUser.getUserID();
            string UserName = txtUserName.Text;
            string Password = txtPassword.Text;
            string Confirm = txtConfirm.Text;
            string FullName = txtFullName.Text;
            string Email = txtEmail.Text;
            string FoneNumber = txtFoneNumber.Text;
            DateTime Birthday = DateTime.Parse(ddlDate.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + ddlYear.SelectedValue);
            string Address = txtAddress.Text;
            string RuleID = "Rul03";
            if (pUser.insertUser(UserID, UserName, Password, FullName, Birthday, Address, FoneNumber, Email, RuleID) > 0)
            {
                Alert.Show("Register successfull!");
                Response.Redirect("index.aspx");
            }
            else
            {
                Alert.Show("Registerun successfull!");
                Response.Redirect("index.aspx?subpara=createaccount");
            }
        }
        catch (Exception)
        {
            Alert.Show("Your input string was not correct format. Please input again!");
        }
    }
}
